package com.cdj.common.activity;

import android.view.KeyEvent;

import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.ToastUtils;

/**
 * ---------------------------------------------------------<br />
 * desc：基础的应用首页功能封装<br />
 * author：chendeji <br />
 * date：2021/6/3<br />
 * email：18701434169@163.com<br />
 * qq: 781571323
 * wx: melody_2009
 * ---------------------------------------------------------<br />
 */
public abstract class BaseMainActivity extends BaseLoadDataActivity{

    private long deltBackClickTime;

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            /**
             * 二次点击退出应用
             * author:陈德基
             * date: 2021/6/3
             */
            long time = System.currentTimeMillis();
            long deltTime = time - deltBackClickTime;
            if (deltTime < 2000) {
                AppUtils.exitApp();
            } else {
                deltBackClickTime = time;
                ToastUtils.showLong("再次点击退出应用");
            }
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

}
